package com.ujiuye.service.impl;

import com.ujiuye.dao.IUserMapper;
import com.ujiuye.domain.po.User;
import com.ujiuye.exceptions.MyException;
import com.ujiuye.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private IUserMapper userMapper;

    @Override
    public void save(User user) {

        User user1 = userMapper.getByUserName(user.getName());
        if (user1 != null) {
            MyException.error("用户名已被注册");
        }
        userMapper.save(user);
        System.out.println("userid == " + user.getUid());
    }

    @Override
    public List<User> findUser(User user) {
        return userMapper.findUser(user);
    }
}
